home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / packet / p_aa4re / mbb35src / 8250ini.asm < prev    next >
Encoding:
Assembly Source File  |  1991-02-16  |  6.4 KB  |  143 lines

  1. ;==========================================================================;
  2. ; 8250 Initialization handler                                              ;
  3. ;   This code also used by the QUADRAM QUADPORT board and 4 async port card;
  4. ;                                                                          ;
  5. ;   Copyright 1983 by William E. Westfield.  All rights reserved.          ;
  6. ;   Copyright 1986, 1987, 1990, 1991 by H. Roy Engehausen.  All rights     ;
  7. ;   reserved.                                                              ;
  8. ;                                                                          ;
  9. ;   This software may be freely distributed and used, but it may not       ;
  10. ;   under any circumstances be sold by anyone other than the author.       ;
  11. ;   It may be distributed by a commercial company as long as it is         ;
  12. ;   for no cost.                                                           ;
  13. ;                                                                          ;
  14. ;==========================================================================;
  15.  
  16.         CMP     chip[SI],chip_8250  ; Is this an 8250?
  17.         JE      init_is_8250        ;      Yep... Do it
  18.         CMP     chip[SI],chip_qrqp  ; Is this a QuadRam QuadPort?
  19.         JE      init_is_8250        ;      Yep... Do it
  20.         CMP     chip[SI],chip_4apc  ; Is this a 4 async port card?
  21.         JE      init_is_8250        ;      Yep... Do it
  22.         JMP     init_not_8250       ;      Nope:  skip this
  23.  
  24. init_is_8250:
  25.  
  26.         MOV     CX,baseaddr[SI]     ; Get base address for chip
  27.  
  28. ;--------------------------------------------------------------------------;
  29. ; Set the FIFO registers in the 16550A                                     ;
  30. ;--------------------------------------------------------------------------;
  31.  
  32.    IF present_fifo
  33.  
  34.         OR      options[SI],opt_fifo ; Turn on FIFO bit
  35.  
  36.         MOV     AL,fcr_8250_trig8+fcr_8250_tclr+fcr_8250_rclr+fcr_8250_enabl ;
  37.  
  38.         MOV     DX,CX               ; Compute port address for the FCR
  39.         ADD     DX,fcr_8250         ;
  40.         OUT     DX,AL               ; Set the FCR
  41.  
  42.         MOV     DX,CX               ; Compute port address for the IIR
  43.         ADD     DX,iir_8250         ;
  44.         IN      AL,DX               ; Get the IIR
  45.  
  46.         AND     AL,iir_8250_fifo    ; See if FIFO bits are on
  47.         CMP     AL,iir_8250_fifo    ;
  48.         JNE     init_8250_nofifo    ; No FIFO mode here
  49.  
  50. ;--------------------------------------------------------------------------;
  51. ; Announce that FIFO was turned on                                         ;
  52. ;--------------------------------------------------------------------------;
  53.  
  54.         MOV     DX,OFFSET msgfifo   ; Message
  55.         MOV     AH,dos_write_line   ; Send to output
  56.         INT     dos_vector_no       ;
  57.  
  58.         JMP     init_8250_fifo      ; FIFO mode is OK
  59.  
  60. msgfifo DB 'FIFO mode enabled',13,10,'$'
  61.  
  62. ;--------------------------------------------------------------------------;
  63. ; FIFO not set.. Turn everything off                                       ;
  64. ;--------------------------------------------------------------------------;
  65.  
  66. init_8250_nofifo:
  67.  
  68.         SUB     AL,AL               ; Clear the FCR
  69.  
  70.         MOV     DX,CX               ; Compute port address for the FCR
  71.         ADD     DX,fcr_8250         ;
  72.         OUT     DX,AL               ; Set the FCR
  73.  
  74.         XOR     options[SI],opt_fifo ; Turn off FIFO bit
  75.  
  76. init_8250_fifo:
  77.  
  78.    ENDIF
  79.  
  80. ;--------------------------------------------------------------------------;
  81. ; Set the interrupt registers in the 8250                                  ;
  82. ;--------------------------------------------------------------------------;
  83.  
  84.         MOV     AL,ier_8250_rda     ; Enable data interrupt only
  85.  
  86.         TEST    options[SI],opt_trbuf ; Transmit buffering turned on?
  87.         JZ      ini_8250_notrbuff   ;           No - Just want only 1 interrupt
  88.         OR      AL,ier_8250_thre+ier_8250_ms ;  Yes - We need both modem status enable
  89.                                     ;                 and THRE interrupts too
  90.  
  91. ini_8250_notrbuff:
  92.  
  93.         MOV     DX,CX               ; Compute port address for the IER
  94.         ADD     DX,ier_8250         ;
  95.         OUT     DX,AL               ; Set the IER
  96.  
  97. ;--------------------------------------------------------------------------;
  98. ; Signal goodness to the outboard equipment                                ;
  99. ;--------------------------------------------------------------------------;
  100.  
  101.         MOV     DX,CX               ; Compute port address for the MCR
  102.         ADD     DX,mcr_8250         ;
  103.         MOV     AL,hon_8250         ; Raise DTR, RTS, and OUT2.  OUT2 turns
  104.                                     ; on interrupts
  105.         OUT     DX,AL               ;
  106.  
  107. ;--------------------------------------------------------------------------;
  108. ; Collect any pending interrupts to ensure okie dokie                      ;
  109. ;--------------------------------------------------------------------------;
  110.  
  111.         MOV     AH,07FH             ; Maximum looping
  112.  
  113. ini_8250_cleani:
  114.  
  115.         MOV     DX,CX               ; Compute port address for the input buffer
  116.         ADD     DX,rbr_8250         ;
  117.         IN      AL,DX               ; Read the input buffer and throw it away
  118.  
  119.         MOV     DX,CX               ; Compute port address for the LSR
  120.         ADD     DX,lsr_8250         ;
  121.         IN      AL,DX               ; Read the LSR and throw it away
  122.  
  123.         MOV     DX,CX               ; Compute port address for the MSR
  124.         ADD     DX,msr_8250         ;
  125.         IN      AL,DX               ; Read the MSR and throw it away
  126.  
  127.         MOV     DX,CX               ; Compute port address for the IIR
  128.         ADD     DX,iir_8250         ;
  129.         IN      AL,DX               ; Read the IIR
  130.  
  131.         AND     AL,iir_8250_ip      ; If no interrupt pending, fall out
  132.         JNZ     ini_8250_cleanid    ;      No interrupt pending
  133.         DEC     AH                  ; Decrement loop counter
  134.         JNZ     ini_8250_cleani     ;      Try cleaning out one more time
  135.  
  136. ini_8250_cleanid:
  137.  
  138. ;--------------------------------------------------------------------------;
  139. ; Done                                                                     ;
  140. ;--------------------------------------------------------------------------;
  141.  
  142. init_not_8250:                      ; Not 8250 come here!
  143.